package org.hrqing.authorization.entity.mapper;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hrqing.authorization.security.Auditor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * @auther Hrqing
 */
@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseAuditingEntity extends BaseEntity {

    @CreatedBy
    @AttributeOverrides({
            @AttributeOverride(name = "id", column = @Column(name = "created_id")),
            @AttributeOverride(name = "name", column = @Column(name = "created_name")),
            @AttributeOverride(name = "certNumber", column = @Column(name = "created_cert_number")),
            @AttributeOverride(name = "mobile", column = @Column(name = "created_mobile")),
    })
    private Auditor auditor;

    @CreatedDate
    private LocalDateTime createdTime;
}
